home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / adasmall / atest3.ada < prev    next >
Text File  |  1996-01-30  |  1KB  |  55 lines

  1. -- This program can be used to demonstrate the scheduling techniques
  2. -- since Task2 will have higher priority than Task1, so more
  3. -- B's will be printed out than A's at a time if scheduled using
  4. -- scheduling techniques 3 and 5
  5.  
  6. with SMALL_SP; use SMALL_SP;
  7. procedure Atest3 is
  8.  
  9.  
  10.    task Task2 is
  11.      entry start;
  12.    end Task2;
  13.  
  14.    task Task1 is
  15.      entry start;
  16.    end Task1;
  17.  
  18.  
  19.    task body Task2 is
  20.      k : INTEGER;
  21.    begin
  22.        accept start;
  23.        for k in 0..20 loop
  24.          PUT("B");
  25.          if (k mod 5 = 0) then
  26.            delay 0.55;
  27.          end if;
  28.        end loop;
  29.    end Task2;
  30.  
  31.    task body Task1 is
  32.      k : INTEGER;
  33.    begin
  34.        accept start;
  35.        for k in 0..20 loop
  36.          PUT("A");
  37.          if (k mod 5 = 0) then
  38.            delay 0.55;
  39.          end if;
  40.        end loop;
  41.    end Task1;
  42.  
  43.  
  44.  
  45. begin
  46.   PUT("In this run Task2 has higher priority than Task1, so more B's");
  47.   NEW_LINE;
  48.   PUT("will be printed at one time than A's if scheduled with 3 or 5");
  49.   NEW_LINE;
  50.   NEW_LINE;
  51.   NEW_LINE;
  52.   Task1.start;
  53.   Task2.start;
  54. end Atest3;
  55.